package com.eqdd.yiqidian.utils;

import android.content.Context;
import android.net.Uri;
import android.text.TextUtils;

import com.eqdd.yiqidian.base.AppConstent;
import com.eqdd.yiqidian.base.BaseActivity;
import com.eqdd.yiqidian.base.loading.wheelprogressdialog.WheelProgressHelper;
import com.eqdd.yiqidian.bean.ParseVideoBean;
import com.eqdd.yiqidian.bean.rebuild.ChuangwenCommonBean;
import com.eqdd.yiqidian.bean.rebuild.CommentResultBean;
import com.eqdd.yiqidian.bean.rebuild.GroupListResultBean;
import com.eqdd.yiqidian.bean.rebuild.YueCommentBean;
import com.eqdd.yiqidian.http.DialogCallBack;
import com.eqdd.yiqidian.http.HttpConfig;
import com.eqdd.yiqidian.http.HttpResult;
import com.eqdd.yiqidian.http.JsonCallBack;
import com.eqdd.yiqidian.ui.yiqixue.LearnPhotoActivity;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import com.lzy.okgo.request.PostRequest;

import java.io.File;
import java.util.List;

import io.rong.imkit.RongIM;
import io.rong.imlib.model.Group;

/**
 * Created by 吕志豪 on 17-10-10  上午11:47.
 * Github :https://github.com/lvzhihao100
 * E-Mail：1030753080@qq.com
 * 简书 :http://www.jianshu.com/u/6e525b929aac
 */

public class HttpUtil {
    public static void refreshGroup() {
        OkGo.<HttpResult<List<GroupListResultBean>>>post(HttpConfig.BASE_URL + HttpConfig.GROUP_LIST_INFO)
                .params("userGuid", GreenDaoUtil.getUser().getGuid())
                .execute(new JsonCallBack<HttpResult<List<GroupListResultBean>>>() {
                    @Override
                    public void onSuccess(Response<HttpResult<List<GroupListResultBean>>> response) {
                        HttpResult<List<GroupListResultBean>> httpResult = response.body();
                        if (httpResult.getStatus() == 200) {
                            GreenDaoUtil.deleteAllGroup();
                            for (GroupListResultBean groupBean : httpResult.getItems()) {
                                GreenDaoUtil.insertGroup(groupBean);
                                Group group = new Group(groupBean.getGroupid(), TextUtils.isEmpty(groupBean.getGroupname()) ? "未命名" : groupBean.getGroupname(), Uri.parse(groupBean.getGroupphoto()));
                                RongIM.getInstance().refreshGroupInfoCache(group);
                            }
                        }
                    }
                });
    }

    public static void upLoadPic(Context context, String filePath, PicBack picBack) {

        WheelProgressHelper wheelProgressHelper = new WheelProgressHelper(context);
        wheelProgressHelper.showLoading("图片上传中");
        OkGo.<HttpResult<String>>post(HttpConfig.BASE_URL + HttpConfig.UPLOAD_IMG)
                .params("image", new File(filePath))
                .execute(new JsonCallBack<HttpResult<String>>() {
                    @Override
                    public void onSuccess(Response<HttpResult<String>> response) {
                        HttpResult<String> httpResult = response.body();
                        if (httpResult.getStatus() == 200) {
                            wheelProgressHelper.hideLoading("上传成功");
                            picBack.onPicBack(httpResult.getItems());
                        } else {
                            wheelProgressHelper.hideLoading("上传失败");
                        }
                    }

                    @Override
                    public void onError(Response<HttpResult<String>> response) {
                        super.onError(response);
                        wheelProgressHelper.hideLoading("上传失败");

                    }
                });

    }

    public static void addArticleMenu(BaseActivity baseActivity, String content, ResultBack resultBack) {
        OkGo.<HttpResult>post(HttpConfig.BASE_URL + HttpConfig.YUE_ARTICLE_ADD_MENU)
                .params("userGuid", AppConstent.user.getGuid())
                .params("menuName", content)
                .execute(new DialogCallBack<HttpResult>(baseActivity) {
                    @Override
                    public void onSuccess(Response<HttpResult> response) {
                        HttpResult httpResult = response.body();
                        ToastUtil.showShort(httpResult.getMsg());
                        if (httpResult.getStatus() == 200) {
                            resultBack.onResultBack();
                        }
                    }
                });
    }

    public static void addChuangwenMenu(BaseActivity baseActivity, String content, ResultBack resultBack) {
        OkGo.<HttpResult>post(HttpConfig.BASE_URL + HttpConfig.CHUANGWEN_ADD_MENU)
                .params("userGuid", AppConstent.user.getGuid())
                .params("categoryName", content)
                .execute(new DialogCallBack<HttpResult>(baseActivity) {
                    @Override
                    public void onSuccess(Response<HttpResult> response) {
                        HttpResult httpResult = response.body();
                        ToastUtil.showShort(httpResult.getMsg());
                        if (httpResult.getStatus() == 200) {
                            resultBack.onResultBack();
                        }
                    }
                });
    }

    public static void updateArticleMenuName(BaseActivity baseActivity, int menuId, String content, ResultBack resultBack) {
        OkGo.<HttpResult>post(HttpConfig.BASE_URL + HttpConfig.YUE_UPDATE_MENU_NAME)
                .params("userGuid", AppConstent.user.getGuid())
                .params("articleMenuId", menuId)
                .params("articleMenuName", content)
                .execute(new DialogCallBack<HttpResult>(baseActivity) {
                    @Override
                    public void onSuccess(Response<HttpResult> response) {
                        HttpResult httpResult = response.body();
                        ToastUtil.showShort(httpResult.getMsg());
                        if (httpResult.getStatus() == 200) {
                            resultBack.onResultBack();
                        }
                    }
                });
    }

    public static void updateChuangwenMenuName(BaseActivity baseActivity, int menuId, String content, ResultBack resultBack) {
        OkGo.<HttpResult>post(HttpConfig.BASE_URL + HttpConfig.CHUANGWEN_UPDATE_MENU_NAME)
                .params("userGuid", AppConstent.user.getGuid())
                .params("categoryId", menuId)
                .params("categoryName", content)
                .execute(new DialogCallBack<HttpResult>(baseActivity) {
                    @Override
                    public void onSuccess(Response<HttpResult> response) {
                        HttpResult httpResult = response.body();
                        ToastUtil.showShort(httpResult.getMsg());
                        if (httpResult.getStatus() == 200) {
                            resultBack.onResultBack();
                        }
                    }
                });
    }

    public static void deleteArticleMenu(BaseActivity baseActivity, int articleId, ResultBack resultBack) {
        OkGo.<HttpResult>post(HttpConfig.BASE_URL + HttpConfig.YUE_DELETE_ARTICLE_MENU)
                .params("userGuid", AppConstent.user.getGuid())
                .params("articleMenuId", articleId)
                .execute(new DialogCallBack<HttpResult>(baseActivity) {
                    @Override
                    public void onSuccess(Response<HttpResult> response) {
                        HttpResult httpResult = response.body();
                        ToastUtil.showShort(httpResult.getMsg());
                        if (httpResult.getStatus() == 200) {
                            resultBack.onResultBack();
                        }
                    }
                });
    }

    public static void deleteChuangwenMenu(BaseActivity baseActivity, int articleId, ResultBack resultBack) {
        OkGo.<HttpResult>post(HttpConfig.BASE_URL + HttpConfig.CHUANGWEN_DELETE_ARTICLE_MENU)
                .params("userGuid", AppConstent.user.getGuid())
                .params("categoryId", articleId)
                .execute(new DialogCallBack<HttpResult>(baseActivity) {
                    @Override
                    public void onSuccess(Response<HttpResult> response) {
                        HttpResult httpResult = response.body();
                        ToastUtil.showShort(httpResult.getMsg());
                        if (httpResult.getStatus() == 200) {
                            resultBack.onResultBack();
                        }
                    }
                });
    }

    public static void commentArticle(BaseActivity baseActivity, int articleId, int parentId, String content, String parentUserGuid, int firstCommentId, ResultObjectBack resultBack) {
        OkGo.<HttpResult<YueCommentBean>>post(HttpConfig.BASE_URL + HttpConfig.YUE_COMMENT_ARTICLE)
                .params("userGuid", AppConstent.user.getGuid())
                .params("articleId", articleId)
                .params("parentid", parentId)
                .params("content", content)
                .params("parentUserGuid", parentUserGuid)
                .params("firstCommentId", firstCommentId)
                .execute(new DialogCallBack<HttpResult<YueCommentBean>>(baseActivity) {
                    @Override
                    public void onSuccess(Response<HttpResult<YueCommentBean>> response) {
                        HttpResult<YueCommentBean> httpResult = response.body();
                        ToastUtil.showShort(httpResult.getMsg());
                        if (httpResult.getStatus() == 200) {
                            resultBack.onResultBack(httpResult.getItems());
                        }
                    }
                });
    }

    public static void commentWorkCircle(BaseActivity baseActivity, int articleId, int parentId, String content, String parentUserGuid, int firstCommentId, ResultObjectBack resultBack) {
        OkGo.<HttpResult<CommentResultBean>>post(HttpConfig.BASE_URL + HttpConfig.WORK_CIRCLE_COMMENT)
                .params("userGuid", AppConstent.user.getGuid())
                .params("companyId", AppConstent.user.getCompanyId())
                .params("workCircleId", articleId)
                .params("parentId", parentId)
                .params("message", content)
                .params("parentUserGuid", parentUserGuid)
                .params("firstCommentId", firstCommentId)
                .execute(new DialogCallBack<HttpResult<CommentResultBean>>(baseActivity) {
                    @Override
                    public void onSuccess(Response<HttpResult<CommentResultBean>> response) {
                        HttpResult<CommentResultBean> httpResult = response.body();
                        ToastUtil.showShort(httpResult.getMsg());
                        if (httpResult.getStatus() == 200) {
                            resultBack.onResultBack(httpResult.getItems());
                        }
                    }
                });
    }

    public static void zanArticle(BaseActivity baseActivity, int articleId, ResultBack resultBack) {
        OkGo.<HttpResult>post(HttpConfig.BASE_URL + HttpConfig.YUE_ZAN_ARTICLE)
                .params("userGuid", AppConstent.user.getGuid())
                .params("articleId", articleId)
                .execute(new DialogCallBack<HttpResult>(baseActivity) {
                    @Override
                    public void onSuccess(Response<HttpResult> response) {
                        HttpResult httpResult = response.body();
                        ToastUtil.showShort(httpResult.getMsg());
                        if (httpResult.getStatus() == 200) {
                            resultBack.onResultBack();
                        }
                    }
                });
    }

    public static void deleteComment(BaseActivity baseActivity, int articleCommentId, int articleId, int type, ResultBack resultBack) {
        OkGo.<HttpResult>post(HttpConfig.BASE_URL + HttpConfig.YUE_DELETE_COMMENT)
                .params("userGuid", AppConstent.user.getGuid())
                .params("articleCommentId", articleCommentId)
                .params("articleId", articleId)
                .params("type", type)
                .execute(new DialogCallBack<HttpResult>(baseActivity) {
                    @Override
                    public void onSuccess(Response<HttpResult> response) {
                        HttpResult httpResult = response.body();
                        ToastUtil.showShort(httpResult.getMsg());
                        if (httpResult.getStatus() == 200) {
                            resultBack.onResultBack();
                        }
                    }
                });
    }

    public static void deleteChuangComment(BaseActivity baseActivity, int articleCommentId, ResultBack resultBack) {
        OkGo.<HttpResult>post(HttpConfig.BASE_URL + HttpConfig.CHUANG_DELETE_COMMENT)
                .params("userGuid", AppConstent.user.getGuid())
                .params("commentId", articleCommentId)
                .execute(new DialogCallBack<HttpResult>(baseActivity) {
                    @Override
                    public void onSuccess(Response<HttpResult> response) {
                        HttpResult httpResult = response.body();
                        ToastUtil.showShort(httpResult.getMsg());
                        if (httpResult.getStatus() == 200) {
                            resultBack.onResultBack();
                        }
                    }
                });
    }

    public static void deleteWorkCircleComment(BaseActivity baseActivity, int commentId, int articleId, int type, ResultBack resultBack) {
        OkGo.<HttpResult>post(HttpConfig.BASE_URL + HttpConfig.DELETE_COMMENT_INFO)
                .params("userGuid", AppConstent.user.getGuid())
                .params("commentId", commentId)
                .params("articleId", articleId)
                .params("type", type)
                .execute(new DialogCallBack<HttpResult>(baseActivity) {
                    @Override
                    public void onSuccess(Response<HttpResult> response) {
                        HttpResult httpResult = response.body();
                        ToastUtil.showShort(httpResult.getMsg());
                        if (httpResult.getStatus() == 200) {
                            resultBack.onResultBack();
                        }
                    }
                });
    }

    public static void attention(String attention, ResultBack resultBack) {
        OkGo.<HttpResult>post(HttpConfig.BASE_URL + HttpConfig.YUE_ADD_ATTENTION)
                .params("userGuid", AppConstent.user.getGuid())
                .params("attention", attention)
                .execute(new JsonCallBack<HttpResult>() {
                    @Override
                    public void onSuccess(Response<HttpResult> response) {
                        HttpResult httpResult = response.body();
                        if (httpResult.getStatus() == 200) {
                            resultBack.onResultBack();
                        }
                    }
                });
    }

    public static void cancleAttention(String attention, ResultBack resultBack) {
        OkGo.<HttpResult>post(HttpConfig.BASE_URL + HttpConfig.YUE_CANCLE_ATTENTION)
                .params("userGuid", AppConstent.user.getGuid())
                .params("author", attention)
                .execute(new JsonCallBack<HttpResult>() {
                    @Override
                    public void onSuccess(Response<HttpResult> response) {
                        HttpResult httpResult = response.body();
                        if (httpResult.getStatus() == 200) {
                            resultBack.onResultBack();
                        }
                    }
                });
    }

    public static void deleteArticle(BaseActivity baseActivity, int articleId, ResultBack resultBack) {
        OkGo.<HttpResult>post(HttpConfig.BASE_URL + HttpConfig.YUE_DELETE_ARTICLE)
                .params("userGuid", AppConstent.user.getGuid())
                .params("articleId", articleId)
                .execute(new DialogCallBack<HttpResult>(baseActivity) {
                    @Override
                    public void onSuccess(Response<HttpResult> response) {
                        HttpResult httpResult = response.body();
                        ToastUtil.showShort(httpResult.getMsg());
                        if (httpResult.getStatus() == 200) {
                            resultBack.onResultBack();
                        }
                    }
                });
    }

    public static void deleteChuangArticle(BaseActivity baseActivity, int articleId, ResultBack resultBack) {
        OkGo.<HttpResult>post(HttpConfig.BASE_URL + HttpConfig.CHUANG_DELETE_ARTICLE)
                .params("userGuid", AppConstent.user.getGuid())
                .params("articleId", articleId)
                .execute(new DialogCallBack<HttpResult>(baseActivity) {
                    @Override
                    public void onSuccess(Response<HttpResult> response) {
                        HttpResult httpResult = response.body();
                        ToastUtil.showShort(httpResult.getMsg());
                        if (httpResult.getStatus() == 200) {
                            resultBack.onResultBack();
                        }
                    }
                });
    }

    public static void zanComment(int articleCommentId, ResultBack resultBack) {
        OkGo.<HttpResult>post(HttpConfig.BASE_URL + HttpConfig.YUE_ZAN_COMMENT)
                .params("userGuid", AppConstent.user.getGuid())
                .params("articleCommentId", articleCommentId)
                .execute(new JsonCallBack<HttpResult>() {
                    @Override
                    public void onSuccess(Response<HttpResult> response) {
                        HttpResult httpResult = response.body();
                        ToastUtil.showShort(httpResult.getMsg());
                        if (httpResult.getStatus() == 200) {
                            resultBack.onResultBack();
                        }
                    }
                });
    }

    public static void zanChuangComment(int id, boolean isArticle, boolean isZan, ResultBack resultBack) {
        OkGo.<HttpResult>post(HttpConfig.BASE_URL + HttpConfig.CHUANG_ZAN_COMMENT)
                .params("userGuid", AppConstent.user.getGuid())
                .params("type", isArticle ? 1 : 2)
                .params("itemId", id)
                .params("operation", isZan ? 1 : -1)
                .execute(new JsonCallBack<HttpResult>() {
                    @Override
                    public void onSuccess(Response<HttpResult> response) {
                        HttpResult httpResult = response.body();
                        ToastUtil.showShort(httpResult.getMsg());
                        if (httpResult.getStatus() == 200) {
                            resultBack.onResultBack();
                        }
                    }
                });
    }

    public static void reportArticle(int articleId, String reportType, String reason, ResultBack resultBack) {
        OkGo.<HttpResult>post(HttpConfig.BASE_URL + HttpConfig.YUE_REPORT_ARTICLE)
                .params("userGuid", AppConstent.user.getGuid())
                .params("articleId", articleId)
                .params("reportType", reportType)
                .params("reason", reason)
                .execute(new JsonCallBack<HttpResult>() {
                    @Override
                    public void onSuccess(Response<HttpResult> response) {
                        HttpResult httpResult = response.body();
                        ToastUtil.showShort(httpResult.getMsg());
                        if (httpResult.getStatus() == 200) {
                            resultBack.onResultBack();
                        }
                    }
                });
    }

    public static void reportChuangArticle(int articleId, String reportType, int itemType, String reason, ResultBack resultBack) {
        OkGo.<HttpResult>post(HttpConfig.BASE_URL + HttpConfig.CHUANG_REPORT_ARTICLE)
                .params("userGuid", AppConstent.user.getGuid())
                .params("itemId", articleId)
                .params("itemType", itemType)
                .params("tipOffType", reportType)
                .params("theContent", reason)
                .execute(new JsonCallBack<HttpResult>() {
                    @Override
                    public void onSuccess(Response<HttpResult> response) {
                        HttpResult httpResult = response.body();
                        ToastUtil.showShort(httpResult.getMsg());
                        if (httpResult.getStatus() == 200) {
                            resultBack.onResultBack();
                        }
                    }
                });
    }

    public static void collectArticle(String title, String url, String content, String sourceOwner, int articleId, ResultBack resultBack) {
        OkGo.<HttpResult>post(HttpConfig.BASE_URL + HttpConfig.ADD_COLLECTION)
                .params("owner", AppConstent.user.getGuid())
                .params("type", 10)
                .params("title", title)
                .params("url", url)
                .params("ccontent", content)
                .params("source", "易企阅")
                .params("sourceOwner", sourceOwner)
                .params("articleId", articleId)
                .execute(new JsonCallBack<HttpResult>() {
                    @Override
                    public void onSuccess(Response<HttpResult> response) {
                        HttpResult httpResult = response.body();
                        ToastUtil.showShort(httpResult.getMsg());
                        if (httpResult.getStatus() == 200) {
                            resultBack.onResultBack();
                        }
                    }
                });
    }

    public static void collectChuangArticle(String title, String url, String content, String sourceOwner, int articleId, ResultBack resultBack) {
        OkGo.<HttpResult>post(HttpConfig.BASE_URL + HttpConfig.ADD_COLLECTION)
                .params("owner", AppConstent.user.getGuid())
                .params("type", 12)
                .params("title", title)
                .params("url", url)
                .params("ccontent", content)
                .params("source", "易企创")
                .params("sourceOwner", sourceOwner)
                .params("articleId", articleId)
                .execute(new JsonCallBack<HttpResult>() {
                    @Override
                    public void onSuccess(Response<HttpResult> response) {
                        HttpResult httpResult = response.body();
                        ToastUtil.showShort(httpResult.getMsg());
                        if (httpResult.getStatus() == 200) {
                            resultBack.onResultBack();
                        }
                    }
                });
    }

    public static void commentChuangArticle(BaseActivity baseActivity, int id, int parentId, String content, String parentUserGuid, int firstCommentId, ResultObjectBack resultBack) {
        OkGo.<HttpResult<ChuangwenCommonBean.SonCmetsBean>>post(HttpConfig.BASE_URL + HttpConfig.CHUANG_COMMENT_ARTICLE)
                .params("userGuid", AppConstent.user.getGuid())
                .params("type", firstCommentId == 0 ? 1 : 2)
                .params("articleId", id)
                .params("upCommentId", parentId)
                .params("commentContext", content)
                .params("theCommentator", parentUserGuid)
                .params("topParCmetId", firstCommentId)
                .execute(new DialogCallBack<HttpResult<ChuangwenCommonBean.SonCmetsBean>>(baseActivity) {
                    @Override
                    public void onSuccess(Response<HttpResult<ChuangwenCommonBean.SonCmetsBean>> response) {
                        HttpResult<ChuangwenCommonBean.SonCmetsBean> httpResult = response.body();
                        ToastUtil.showShort(httpResult.getMsg());
                        if (httpResult.getStatus() == 200) {
                            resultBack.onResultBack(httpResult.getItems());
                        }
                    }
                });
    }

    public static void addImgToCollection(String source, String sourceOwner, String imageUrl, String imagePath) {
        PostRequest<HttpResult> params = OkGo.<HttpResult>post(HttpConfig.BASE_URL + HttpConfig.ADD_COLLECTION)
                .params("owner", AppConstent.user.getGuid())
                .params("type", TextUtils.isEmpty(imageUrl) ? 1 : 8)
                .params("url", imageUrl)
                .params("tel", AppConstent.user.getUname())
                .params("source", source)
                .params("sourceOwner", sourceOwner);
        if (!TextUtils.isEmpty(imagePath)) {
            params.params("file", new File(imagePath));
        }
        params.execute(new JsonCallBack<HttpResult>() {
            @Override
            public void onSuccess(Response<HttpResult> response) {
                HttpResult httpResult = response.body();
                ToastUtil.showShort(httpResult.getMsg());
            }
        });
    }

    public static void addLinkToCollection(String source, String sourceOwner, String url, String title) {
        OkGo.<HttpResult>post(HttpConfig.BASE_URL + HttpConfig.ADD_COLLECTION)
                .params("owner", AppConstent.user.getGuid())
                .params("type", 7)
                .params("url", url)
                .params("title", title)
                .params("tel", AppConstent.user.getUname())
                .params("source", source)
                .params("sourceOwner", sourceOwner)
                .execute(new JsonCallBack<HttpResult>() {
                    @Override
                    public void onSuccess(Response<HttpResult> response) {
                        HttpResult httpResult = response.body();
                        ToastUtil.showShort(httpResult.getMsg());
                    }
                });
    }

    public static void addTextToCollection(String source, String sourceOwner, String content, String title) {
        OkGo.<HttpResult>post(HttpConfig.BASE_URL + HttpConfig.ADD_COLLECTION)
                .params("owner", AppConstent.user.getGuid())
                .params("type", 7)
                .params("ccontent", content)
                .params("title", title)
                .params("tel", AppConstent.user.getUname())
                .params("source", source)
                .params("sourceOwner", sourceOwner)
                .execute(new JsonCallBack<HttpResult>() {
                    @Override
                    public void onSuccess(Response<HttpResult> response) {
                        HttpResult httpResult = response.body();
                        ToastUtil.showShort(httpResult.getMsg());
                    }
                });
    }

    public static void parseVideo(String content, ResultObjectBack resultObjectBack) {
        OkGo.<HttpResult<ParseVideoBean>>post(HttpConfig.BASE_URL + HttpConfig.PARSE_VIDEO)
                .params("videoUrl", content)
                .execute(new JsonCallBack<HttpResult<ParseVideoBean>>() {
                    @Override
                    public void onSuccess(Response<HttpResult<ParseVideoBean>> response) {
                        HttpResult<ParseVideoBean> httpResult = response.body();
                        ToastUtil.showShort(httpResult.getMsg());
                        if (httpResult.getStatus() == 200) {
                            resultObjectBack.onResultBack(httpResult.getItems());
                        } else {
                            resultObjectBack.onResultBack(null);
                        }
                    }

                    @Override
                    public void onError(Response<HttpResult<ParseVideoBean>> response) {
                        super.onError(response);
                        resultObjectBack.onResultBack(null);
                    }
                });
    }

    public static void deleteLearnPhotoMenu(BaseActivity baseActivity, int menuId, ResultBack resultBack) {
        OkGo.<HttpResult>post(HttpConfig.BASE_URL + HttpConfig.LEARN_DELETE_PHOTO_MENU)
                .params("userGuid", AppConstent.user.getGuid())
                .params("menuId", menuId)
                .execute(new DialogCallBack<HttpResult>(baseActivity) {
                    @Override
                    public void onSuccess(Response<HttpResult> response) {
                        HttpResult httpResult = response.body();
                        ToastUtil.showShort(httpResult.getMsg());
                        if (httpResult.getStatus() == 200) {
                            resultBack.onResultBack();
                        }
                    }
                });
    }

    public static void createLearnPhotoMenu(BaseActivity baseActivity, String photoMenuTitle, ResultBack resultBack) {
        OkGo.<HttpResult>post(HttpConfig.BASE_URL + HttpConfig.LEARN_CREATE_PHOTO_MENU)
                .params("userGuid", AppConstent.user.getGuid())
                .params("title", photoMenuTitle)
                .execute(new DialogCallBack<HttpResult>(baseActivity) {
                    @Override
                    public void onSuccess(Response<HttpResult> response) {
                        HttpResult httpResult = response.body();
                        ToastUtil.showShort(httpResult.getMsg());
                        if (httpResult.getStatus() == 200) {
                            resultBack.onResultBack();
                        }
                    }
                });
    }

    public static void deleteLearnPhoto(BaseActivity baseActivity, int lecturePhotoId, int menuId, ResultBack resultBack) {
        OkGo.<HttpResult>post(HttpConfig.BASE_URL + HttpConfig.LEARN_DELETE_PHOTO)
                .params("userGuid", AppConstent.user.getGuid())
                .params("lecturePhotoId", lecturePhotoId)
                .params("menuId", menuId)
                .execute(new DialogCallBack<HttpResult>(baseActivity) {
                    @Override
                    public void onSuccess(Response<HttpResult> response) {
                        HttpResult httpResult = response.body();
                        ToastUtil.showShort(httpResult.getMsg());
                        if (httpResult.getStatus() == 200) {
                            resultBack.onResultBack();
                        }
                    }
                });
    }

    public static void setLearnPhotoMenuBg(BaseActivity baseActivity, int imageId, int menuId) {
        OkGo.<HttpResult>post(HttpConfig.BASE_URL + HttpConfig.LEARN_SET_PHOTO_BG)
                .params("userGuid", AppConstent.user.getGuid())
                .params("imageId", imageId)
                .params("menuId", menuId)
                .execute(new DialogCallBack<HttpResult>(baseActivity) {
                    @Override
                    public void onSuccess(Response<HttpResult> response) {
                        HttpResult httpResult = response.body();
                        ToastUtil.showShort(httpResult.getMsg());
                        if (httpResult.getStatus() == 200) {

                        }
                    }
                });
    }

    public static void updateLearnPhotoMenuName(BaseActivity activity, int menuId, String title, ResultBack resultBack) {
        OkGo.<HttpResult>post(HttpConfig.BASE_URL + HttpConfig.LEARN_UPDATE_PHOTO_MENU_NAME)
                .params("userGuid", AppConstent.user.getGuid())
                .params("menuName", title)
                .params("menuId", menuId)
                .execute(new DialogCallBack<HttpResult>(activity) {
                    @Override
                    public void onSuccess(Response<HttpResult> response) {
                        HttpResult httpResult = response.body();
                        ToastUtil.showShort(httpResult.getMsg());
                        if (httpResult.getStatus() == 200) {
                            resultBack.onResultBack();
                        }
                    }
                });
    }


    public interface PicBack {
        void onPicBack(String url);
    }

    public interface ResultBack {
        void onResultBack();
    }

    public interface ResultObjectBack {
        void onResultBack(Object object);
    }

}
